#include "MutaScene.h"
#include "MutaLine.h"


MutaScene::MutaScene(QObject *parent) :
    QGraphicsScene(parent)
{
    backgroundColor.setRgb( 0, 100, 150 );
}

MutaScene::~MutaScene()
{

}

void MutaScene::deleteItem(QGraphicsItem *item)
{
    QWriteLocker writeLocker(&itemLock);
    int type =  ((MutaLine*)item)->getType();
    qDebug() << "deleting item: " <<  type;
    if(type!=Muta::ControlPoint) {
        emit deletingItem(((MutaLine*)item)->getObjectID());
        delete item;
    }
}

void MutaScene::addItem(QGraphicsItem *item)
{
    QWriteLocker writeLocker(&itemLock);
    QGraphicsScene::addItem(item);
}

/*
QList<QGraphicsItem* > MutaScene::items()
{
    QReadLocker readlocker(&itemLock);
    return QGraphicsScene::items();

}
*/

QReadWriteLock* MutaScene::getItemLock()
{
    return &itemLock;
}
